import request from './request'
import { useUserStore } from "../store/modules/user"
/**
 * 
 * @param data 知识中心分类接口 - 新增或修改知识库分类
 * @returns 
 */
export function knowledgeTypeSave(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/type/save',
        method: 'post',
        headers: token,
        data
    })
}

/**
 * 知识中心分类接口 - 获取知识库分类列表
 * @param data 
 * @returns 
 */
export function getKnowledgeTypeList(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/type/getList',
        method: 'post',
        headers: token,
        data
    })
}

/**
 * 知识中心分类接口 - 根据知识库分类ID获取详情
 * @param id 
 * @returns 
 */
export function getKnowledgeTypeDetail(id: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: `/knowledge/type/${id}`,
        method: 'GET',
        headers: token,
    })
}

/**
 * 知识中心分类接口 - 批量启用或禁用知识库分类
 * @param status 知识库分类状态：false-启用，true-禁用 
 * @param data 知识库分类ID数组
 * @returns 
 */
export function updateKnowledgeTypeDisable(status: boolean, data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: `/knowledge/type/disable?status=${status}`,
        method: 'PUT',
        headers: token,
        data
    })
}

/**
 * 知识中心分类接口 - 批量删除知识库分类
 * @param data 知识库分类ID数组
 * @returns 
 */
export function deleteKnowledgeType(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: `/knowledge/type/delete`,
        method: 'DELETE',
        headers: token,
        data
    })
}


/**
 * 知识中心类下拉接口 - 知识库分类下拉数据列表
 * @param data
 * @returns 
 */
export function knowledgeTypepageSelect(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: `/knowledge/select/knowledgeTypepageSelect`,
        method: 'POST',
        headers: token,
        data
    })
}



// 获取说明书列表
export function instrList(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/instruction-book/getList',
        method: 'post',
        headers: token,
        data
    })
}

// 新增或修改说明书
export function instrSave(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/instruction-book/save',
        method: 'post',
        headers: token,
        data: data
    })
}

// 获取说明书信息
export function instrInfo(id: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/instruction-book/' + id,
        method: 'get',
        headers: token
    })
}

// 批量启用或禁用说明书
export function instrDisable(data: any, status: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/instruction-book/disable',
        method: 'put',
        headers: token,
        data,
        params: { status: status }
    })
}

// 批量删除说明书
export function instrDelete(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/instruction-book/',
        method: 'delete',
        headers: token,
        data,
    })
}

// 获取视频列表
export function videoList(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/video/getList',
        method: 'post',
        headers: token,
        data
    })
}

// 新增或修改视频
export function videoSave(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/video/save',
        method: 'post',
        headers: token,
        data
    })
}

// 获取视频信息
export function videoInfo(id: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/video/' + id,
        method: 'get',
        headers: token
    })
}

// 批量启用或禁用视频
export function videoDisable(data: any, status: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/video/disable',
        method: 'put',
        headers: token,
        data,
        params: { status: status }
    })
}

// 批量删除视频
export function videoDelete(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/video/',
        method: 'delete',
        headers: token,
        data,
    })
}

// 获取故障列表
export function faultList(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/fault/getList',
        method: 'post',
        headers: token,
        data
    })
}

// 新增或修改故障
export function saveFault(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/fault/save',
        method: 'post',
        headers: token,
        data
    })
}

// 获取故障详情
export function detailFault(id: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/fault/' + id,
        method: 'get',
        headers: token,
    })
}

// 批量启用或禁用故障
export function disableFault(data: any, status: boolean) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/fault/disable',
        method: 'put',
        headers: token,
        data,
        params: { status }
    })
}

// 批量启用或禁用故障
export function deleteFault(data: any) {
    let token = {
        'access-token': useUserStore().token
    }
    return request({
        url: '/knowledge/fault/',
        method: 'delete',
        headers: token,
        data,
    })
}